package com.wendu.oa.common;

public class Result {

    public static final int CODE_OK = 200;
    public static final int CODE_ERR_BUSINESS = 500;//用于用户操作导致的错误
    public static final int CODE_ERR_SYS = 530;//用于系统问题导致的错误
    public static final int CODE_ERR_UNLONINED = 520;//用户未登录

    public static Result OK(){
        return new Result(CODE_OK,true,null, null);
    }

    public static Result OK(String message){
        return new Result(CODE_OK,true,message, null);
    }

    public static Result OK(Object data){
        return new Result(CODE_OK,true,null, data);
    }

    public static Result OK(String message, Object data){
        return new Result(CODE_OK,true,message, data);
    }

    public static Result err(int code, String message){
        return new Result(code,false,message, null);
    }

    public static Result err(int code, String message, Object data){
        return new Result(code,false,message, data);
    }

    private int code;
    private boolean success;
    private String message;
    private Object data;

    private Result(int code, boolean success, String message, Object data) {
        this.code = code;
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public boolean isSuccess() {
        return success;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
